﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace LightLog.Framework
{
    public class Security
    {
        /// <summary>
        /// uff8格式的md5
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static string GetMD5UTF8(string str)
        {
            byte[] b = Encoding.UTF8.GetBytes(str);
            b = new MD5CryptoServiceProvider().ComputeHash(b);
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < b.Length; i++)
                sb.Append(b[i].ToString("x").PadLeft(2, '0'));
            return sb.ToString();
        }

        /// <summary>
        /// 获取密码的md5
        /// </summary>
        /// <param name="pwd">密码</param>
        /// <returns></returns>
        public static string GetMd5Pwd(string pwd)
        {
            string info = pwd + "61ca4367e82e7f201e37faf6bb4c8b0b"; //加盐值
            return GetMD5UTF8(info);
        }
    }
}
